/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Design.java
 *
 * Created on Oct 16, 2012, 8:25:51 PM
 */
package test.shashindra;

import utilities.*;
import com.googlecode.javacv.CanvasFrame;
import test.shanika.*;
import java.awt.Color;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.Action;
import java.awt.image.BufferedImage;
import javax.swing.ImageIcon;
import static com.googlecode.javacv.cpp.opencv_core.*;
import com.googlecode.javacv.cpp.opencv_core.IplImage;
import controller.ColorMeanController;
import controller.SkinBasedController;
import java.awt.BasicStroke;
import java.awt.Graphics2D;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.ButtonGroup;
import javax.swing.JFileChooser;
import javax.swing.Timer;
import static com.googlecode.javacv.cpp.opencv_imgproc.*;

/**
 *
 * @author HOME
 */
public class FinalGUICopy extends javax.swing.JFrame {

    /** Creates new form Design */
    private ImageIcon ic1 = new ImageIcon();
    private ImageIcon ic2 = new ImageIcon();
    private ImageIcon ic3 = new ImageIcon();
    private ImageIcon ic4 = new ImageIcon();
    private static IplImage[][] imgArr = new IplImage[2][2];
    static boolean isImageSet = false;
    private static CvSize imSize = new CvSize(217, 187);
    private static IplImage tempIm = cvCreateImage(imSize, 8, 3);
    private static IplImage tempSkin = cvCreateImage(imSize, 8, 1);
    private static IplImage tempIm2 = cvCreateImage(imSize, 8, 3);
    private static IplImage tempSkin2 = cvCreateImage(imSize, 8, 1);
    private static int x;
    private static int y;
    String stylus = "finger";
    private int prevX = 0, prevY = 0;
    Timer timer;
    Thread thread;
    Color linecolor = Color.BLACK;
    ButtonGroup colorButton = new ButtonGroup();
    private boolean viewCamPressed = false;
    private boolean clearSet = false;
    Graphics2D g;
    JFileChooser fc = new JFileChooser();
    File file;
    BufferedImage bf;

    public static void setX_Y(int x, int y) {
        FinalGUICopy.x = x;
        FinalGUICopy.y = y;
    }

    public static int initializeCamera() {
        if (!isImageSet) {
            isImageSet = true;
            return 0;
        } else {
            return 1;
        }
    }

//    public void setkX_kY(int x, int y) {
//        Design1.kx = x;
//        Design1.ky = y;
//    }
    public static void setCamera(IplImage liveCam, IplImage skin, int ImageNo) {

        FinalGUICopy.imgArr[ImageNo][0] = liveCam;
        FinalGUICopy.imgArr[ImageNo][1] = skin;

    }

    public BufferedImage getLiveCam1(int num) {
         System.out.println("came here 21");
        if (num == 0) {
             System.out.println("came here 31");
             //System.out.println(tempIm.width()","+tempIm.height()+","+tempIm.depth());
            cvResize(imgArr[num][0], tempIm);
             System.out.println("came here 41");
            return tempIm.getBufferedImage();
        } else {
              System.out.println("came here 51");
            cvResize(imgArr[num][0], tempIm2);
             System.out.println("came here 61");
            return tempIm2.getBufferedImage();
        }

    }

    public BufferedImage getSkin1(int num) {
        if (num == 0) {
            cvResize(imgArr[num][1], tempSkin);
            return tempSkin.getBufferedImage();
        } else {
            cvResize(imgArr[num][1], tempSkin2);
            return tempSkin2.getBufferedImage();
        }
    }

    public FinalGUICopy() {
        initComponents();
        colorButton.add(blackRadioButton);
        colorButton.add(blueRadioButton);
        colorButton.add(greenRadioButton);
        colorButton.add(redRadioButton);
        blackRadioButton.setSelected(true);
        g = (Graphics2D) drawingPanel.getGraphics();

//        g2 = (Graphics2D) drawingPanel.getGraphics();

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        drawingPanel = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        leftPanel = new javax.swing.JPanel();
        leftLivecamPanel = new javax.swing.JPanel();
        leftLiveCamLabel = new javax.swing.JLabel();
        leftSkinPanel = new javax.swing.JPanel();
        leftSkinLabel = new javax.swing.JLabel();
        rightPanel = new javax.swing.JPanel();
        jPanel9 = new javax.swing.JPanel();
        rightSkinLabel = new javax.swing.JLabel();
        jPanel7 = new javax.swing.JPanel();
        rightLiveCamLabel = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jPanel5 = new javax.swing.JPanel();
        jSlider1 = new javax.swing.JSlider(1,10,5);
        jPanel6 = new javax.swing.JPanel();
        blackRadioButton = new javax.swing.JRadioButton();
        redRadioButton = new javax.swing.JRadioButton();
        greenRadioButton = new javax.swing.JRadioButton();
        blueRadioButton = new javax.swing.JRadioButton();
        jToolBar1 = new javax.swing.JToolBar();
        startButton = new javax.swing.JButton();
        stopButton = new javax.swing.JButton();
        cameraButton = new javax.swing.JButton();
        jToolBar2 = new javax.swing.JToolBar();
        penButton = new javax.swing.JButton();
        eraserButton = new javax.swing.JButton();
        clearScreen = new javax.swing.JButton();
        imageButton = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        deviceMenu1 = new javax.swing.JMenuItem();
        stopMenu = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        fingerMenu = new javax.swing.JRadioButtonMenuItem();
        redMenu = new javax.swing.JRadioButtonMenuItem();
        jMenu3 = new javax.swing.JMenu();
        leftCamMenu = new javax.swing.JMenuItem();
        rightCamMenu = new javax.swing.JMenuItem();
        jMenu4 = new javax.swing.JMenu();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenuItem8 = new javax.swing.JMenuItem();
        jMenuItem7 = new javax.swing.JMenuItem();
        jMenu5 = new javax.swing.JMenu();
        jMenuItem9 = new javax.swing.JMenuItem();
        jMenuItem10 = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Interactive Surface");
        setAlwaysOnTop(true);
        setBounds(new java.awt.Rectangle(0, 0, 0, 0));
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setExtendedState(MAXIMIZED_BOTH);
        setFocusTraversalPolicyProvider(true);

        drawingPanel.setBackground(new java.awt.Color(255, 255, 255));
        drawingPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true), "Screen", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12))); // NOI18N
        drawingPanel.setNextFocusableComponent(drawingPanel);
        drawingPanel.setOpaque(false);
        drawingPanel.setPreferredSize(new java.awt.Dimension(800, 600));

        javax.swing.GroupLayout drawingPanelLayout = new javax.swing.GroupLayout(drawingPanel);
        drawingPanel.setLayout(drawingPanelLayout);
        drawingPanelLayout.setHorizontalGroup(
            drawingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 807, Short.MAX_VALUE)
        );
        drawingPanelLayout.setVerticalGroup(
            drawingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 659, Short.MAX_VALUE)
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true), "Display", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12))); // NOI18N

        leftPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Left Camera", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12))); // NOI18N

        leftLivecamPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Live Camera", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12))); // NOI18N
        leftLivecamPanel.setPreferredSize(new java.awt.Dimension(210, 210));

        javax.swing.GroupLayout leftLivecamPanelLayout = new javax.swing.GroupLayout(leftLivecamPanel);
        leftLivecamPanel.setLayout(leftLivecamPanelLayout);
        leftLivecamPanelLayout.setHorizontalGroup(
            leftLivecamPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(leftLivecamPanelLayout.createSequentialGroup()
                .addComponent(leftLiveCamLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE)
                .addContainerGap())
        );
        leftLivecamPanelLayout.setVerticalGroup(
            leftLivecamPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(leftLiveCamLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 180, Short.MAX_VALUE)
        );

        leftSkinPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Skin Image", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12))); // NOI18N
        leftSkinPanel.setPreferredSize(new java.awt.Dimension(210, 210));

        javax.swing.GroupLayout leftSkinPanelLayout = new javax.swing.GroupLayout(leftSkinPanel);
        leftSkinPanel.setLayout(leftSkinPanelLayout);
        leftSkinPanelLayout.setHorizontalGroup(
            leftSkinPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(leftSkinPanelLayout.createSequentialGroup()
                .addComponent(leftSkinLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 196, Short.MAX_VALUE)
                .addContainerGap())
        );
        leftSkinPanelLayout.setVerticalGroup(
            leftSkinPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(leftSkinLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 180, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout leftPanelLayout = new javax.swing.GroupLayout(leftPanel);
        leftPanel.setLayout(leftPanelLayout);
        leftPanelLayout.setHorizontalGroup(
            leftPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(leftPanelLayout.createSequentialGroup()
                .addComponent(leftLivecamPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 221, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(leftSkinPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 218, Short.MAX_VALUE))
        );
        leftPanelLayout.setVerticalGroup(
            leftPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, leftPanelLayout.createSequentialGroup()
                .addGroup(leftPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(leftSkinPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 207, Short.MAX_VALUE)
                    .addComponent(leftLivecamPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 207, Short.MAX_VALUE))
                .addContainerGap())
        );

        rightPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Right Camera", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12))); // NOI18N

        jPanel9.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Skin Image", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12))); // NOI18N
        jPanel9.setPreferredSize(new java.awt.Dimension(210, 210));

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addComponent(rightSkinLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 194, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(rightSkinLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 205, Short.MAX_VALUE)
        );

        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Live Camera", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12))); // NOI18N
        jPanel7.setPreferredSize(new java.awt.Dimension(210, 210));

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addComponent(rightLiveCamLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 201, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addComponent(rightLiveCamLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 194, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout rightPanelLayout = new javax.swing.GroupLayout(rightPanel);
        rightPanel.setLayout(rightPanelLayout);
        rightPanelLayout.setHorizontalGroup(
            rightPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(rightPanelLayout.createSequentialGroup()
                .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, 223, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel9, javax.swing.GroupLayout.DEFAULT_SIZE, 216, Short.MAX_VALUE))
        );
        rightPanelLayout.setVerticalGroup(
            rightPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, 232, Short.MAX_VALUE)
            .addComponent(jPanel9, javax.swing.GroupLayout.DEFAULT_SIZE, 232, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(leftPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(rightPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(leftPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(rightPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true), "Pen", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12))); // NOI18N

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Line Width", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12))); // NOI18N
        jPanel5.setFont(new java.awt.Font("Tahoma", 0, 12));

        jSlider1.setForeground(new java.awt.Color(0, 0, 0));
        jSlider1.setMajorTickSpacing(1);
        jSlider1.setMaximum(10);
        jSlider1.setPaintLabels(true);
        jSlider1.setPaintTicks(true);
        jSlider1.setPaintTrack(true);
        jSlider1.setSnapToTicks(true);
        jSlider1.setValue(5);
        jSlider1.setAutoscrolls(true);

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jSlider1, javax.swing.GroupLayout.DEFAULT_SIZE, 232, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addComponent(jSlider1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(16, Short.MAX_VALUE))
        );

        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Color", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12))); // NOI18N

        blackRadioButton.setFont(new java.awt.Font("Tahoma", 1, 12));
        blackRadioButton.setText("Black");
        blackRadioButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                blackRadioButtonActionPerformed(evt);
            }
        });

        redRadioButton.setFont(new java.awt.Font("Tahoma", 1, 12));
        redRadioButton.setText("Red");
        redRadioButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                redRadioButtonActionPerformed(evt);
            }
        });

        greenRadioButton.setFont(new java.awt.Font("Tahoma", 1, 12));
        greenRadioButton.setText("Green");
        greenRadioButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                greenRadioButtonActionPerformed(evt);
            }
        });

        blueRadioButton.setFont(new java.awt.Font("Tahoma", 1, 12));
        blueRadioButton.setText("Blue");
        blueRadioButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                blueRadioButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(blackRadioButton)
                    .addComponent(blueRadioButton))
                .addGap(36, 36, 36)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(greenRadioButton)
                    .addComponent(redRadioButton))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(blackRadioButton)
                    .addComponent(greenRadioButton))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(blueRadioButton)
                    .addComponent(redRadioButton)))
        );

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(12, 12, 12)
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel6, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .addComponent(jPanel5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        jToolBar1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jToolBar1.setOrientation(1);
        jToolBar1.setRollover(true);
        jToolBar1.setAutoscrolls(true);

        startButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/test/shanika/Play.png"))); // NOI18N
        startButton.setToolTipText("Start Device");
        startButton.setFocusable(false);
        startButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        startButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        startButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                startButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(startButton);

        stopButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/test/shanika/Stop playing.png"))); // NOI18N
        stopButton.setToolTipText("Stop Device");
        stopButton.setFocusable(false);
        stopButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        stopButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        stopButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                stopButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(stopButton);

        cameraButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/test/shanika/Camera.png"))); // NOI18N
        cameraButton.setToolTipText("Show Cameras");
        cameraButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        cameraButton.setOpaque(false);
        cameraButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        cameraButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cameraButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(cameraButton);

        jToolBar2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jToolBar2.setOrientation(1);
        jToolBar2.setRollover(true);

        penButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/test/shanika/Pen.png"))); // NOI18N
        penButton.setToolTipText("Pen");
        penButton.setFocusable(false);
        penButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        penButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        penButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                penButtonActionPerformed(evt);
            }
        });
        jToolBar2.add(penButton);

        eraserButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/test/shanika/Eraser.png"))); // NOI18N
        eraserButton.setToolTipText("Eraser");
        eraserButton.setFocusable(false);
        eraserButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        eraserButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        eraserButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                eraserButtonActionPerformed(evt);
            }
        });
        jToolBar2.add(eraserButton);

        clearScreen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/test/shanika/Clear.png"))); // NOI18N
        clearScreen.setToolTipText("Clear Screen");
        clearScreen.setFocusable(false);
        clearScreen.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        clearScreen.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        clearScreen.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                clearScreenActionPerformed(evt);
            }
        });
        jToolBar2.add(clearScreen);

        imageButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/test/shanika/New image.png"))); // NOI18N
        imageButton.setToolTipText("Insert Image");
        imageButton.setFocusable(false);
        imageButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        imageButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        imageButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                imageButtonActionPerformed(evt);
            }
        });
        jToolBar2.add(imageButton);

        jMenu1.setText("Device");
        jMenu1.setFont(new java.awt.Font("Arial", 1, 12));

        deviceMenu1.setFont(new java.awt.Font("Arial", 1, 12));
        deviceMenu1.setText("Start Device");
        deviceMenu1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deviceMenu1ActionPerformed(evt);
            }
        });
        jMenu1.add(deviceMenu1);

        stopMenu.setFont(new java.awt.Font("Arial", 1, 12));
        stopMenu.setText("Stop Device");
        stopMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                stopMenuActionPerformed(evt);
            }
        });
        jMenu1.add(stopMenu);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Stylus");
        jMenu2.setFont(new java.awt.Font("Arial", 1, 12));

        buttonGroup1.add(fingerMenu);
        fingerMenu.setSelected(true);
        fingerMenu.setText("Finger");
        fingerMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                fingerMenuActionPerformed(evt);
            }
        });
        jMenu2.add(fingerMenu);

        buttonGroup1.add(redMenu);
        redMenu.setText("Red Stylus");
        redMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                redMenuActionPerformed(evt);
            }
        });
        jMenu2.add(redMenu);

        jMenuBar1.add(jMenu2);

        jMenu3.setText("Display");
        jMenu3.setFont(new java.awt.Font("Arial", 1, 12));

        leftCamMenu.setFont(new java.awt.Font("Arial", 1, 12));
        leftCamMenu.setText("Start Left Camera");
        leftCamMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                leftCamMenuActionPerformed(evt);
            }
        });
        jMenu3.add(leftCamMenu);

        rightCamMenu.setFont(new java.awt.Font("Arial", 1, 12));
        rightCamMenu.setText("Start Right Camera");
        rightCamMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rightCamMenuActionPerformed(evt);
            }
        });
        jMenu3.add(rightCamMenu);

        jMenuBar1.add(jMenu3);

        jMenu4.setText("Application");
        jMenu4.setFont(new java.awt.Font("Arial", 1, 12));

        jMenuItem2.setFont(new java.awt.Font("Arial", 1, 12));
        jMenuItem2.setText("Free Hand");
        jMenu4.add(jMenuItem2);

        jMenuItem8.setFont(new java.awt.Font("Arial", 1, 12));
        jMenuItem8.setText("Power Point");
        jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem8ActionPerformed(evt);
            }
        });
        jMenu4.add(jMenuItem8);

        jMenuItem7.setFont(new java.awt.Font("Arial", 1, 12));
        jMenuItem7.setText("Photo Viewer");
        jMenu4.add(jMenuItem7);

        jMenuBar1.add(jMenu4);

        jMenu5.setText("Tools");
        jMenu5.setFont(new java.awt.Font("Arial", 1, 12));

        jMenuItem9.setText("Eraser");
        jMenuItem9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem9ActionPerformed(evt);
            }
        });
        jMenu5.add(jMenuItem9);

        jMenuItem10.setText("Clear Screen");
        jMenu5.add(jMenuItem10);

        jMenuBar1.add(jMenu5);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(drawingPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 817, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jToolBar2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(drawingPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 684, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(39, 39, 39)
                        .addComponent(jToolBar2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(314, 314, 314))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void blackRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_blackRadioButtonActionPerformed
        linecolor = Color.BLACK;
}//GEN-LAST:event_blackRadioButtonActionPerformed

    private void deviceMenu1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deviceMenu1ActionPerformed
        startButton.setEnabled(false);
        stopButton.setEnabled(true);
        SkinBasedController sbc = new SkinBasedController(0, 1);
        thread = new Thread(sbc);
        thread.start();
        timer = new Timer(15, paintTimer);
        timer.start();
    }//GEN-LAST:event_deviceMenu1ActionPerformed

    private void leftCamMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_leftCamMenuActionPerformed
        viewCamPressed = true;
    }//GEN-LAST:event_leftCamMenuActionPerformed

    private void stopMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stopMenuActionPerformed
        startButton.setEnabled(true);
        stopButton.setEnabled(false);
        deviceMenu1.setEnabled(true);
        stopMenu.setEnabled(false);
        thread.stop();
    }//GEN-LAST:event_stopMenuActionPerformed

    private void greenRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_greenRadioButtonActionPerformed
        linecolor = Color.GREEN;
    }//GEN-LAST:event_greenRadioButtonActionPerformed

    private void blueRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_blueRadioButtonActionPerformed
        linecolor = Color.BLUE;
    }//GEN-LAST:event_blueRadioButtonActionPerformed

    private void redRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_redRadioButtonActionPerformed
        linecolor = Color.RED;
    }//GEN-LAST:event_redRadioButtonActionPerformed

    private void jMenuItem9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem9ActionPerformed
        linecolor = Color.WHITE;
    }//GEN-LAST:event_jMenuItem9ActionPerformed

    private void rightCamMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rightCamMenuActionPerformed
        viewCamPressed = true;
    }//GEN-LAST:event_rightCamMenuActionPerformed

    private void cameraButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cameraButtonActionPerformed

        viewCamPressed = true;
    }//GEN-LAST:event_cameraButtonActionPerformed

    private void startButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_startButtonActionPerformed

        startButton.setEnabled(false);
        stopButton.setEnabled(true);
        if (stylus.equalsIgnoreCase("finger")) {
            SkinBasedController sbc = new SkinBasedController(3, 2);
            thread = new Thread(sbc);
            thread.start();
            timer = new Timer(15, paintTimer);
            timer.start();
        }else{
            ColorMeanController sbc = new ColorMeanController(2, 3);
            thread = new Thread(sbc);
            thread.start();
            timer = new Timer(15, paintTimer);
            timer.start();
        
        }


    }//GEN-LAST:event_startButtonActionPerformed

    private void stopButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stopButtonActionPerformed
        startButton.setEnabled(true);
        stopButton.setEnabled(false);
        deviceMenu1.setEnabled(true);
        stopMenu.setEnabled(false);
        thread.stop();
    }//GEN-LAST:event_stopButtonActionPerformed

    private void eraserButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_eraserButtonActionPerformed
        linecolor = getBackground();
    }//GEN-LAST:event_eraserButtonActionPerformed

    private void penButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_penButtonActionPerformed
        blackRadioButton.setSelected(true);
        linecolor = Color.BLACK;
    }//GEN-LAST:event_penButtonActionPerformed

    private void clearScreenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clearScreenActionPerformed
        clearSet = true;

    }//GEN-LAST:event_clearScreenActionPerformed

    private void imageButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_imageButtonActionPerformed
        setBackgroundImage();
    }//GEN-LAST:event_imageButtonActionPerformed

    private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem8ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItem8ActionPerformed

    private void fingerMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fingerMenuActionPerformed
        if (redMenu.isSelected()) {
            stylus = "red";
        } else {
            stylus = "finger";
        }
        // TODO add your handling code here:
    }//GEN-LAST:event_fingerMenuActionPerformed

    private void redMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_redMenuActionPerformed
        if (redMenu.isSelected()) {
            stylus = "red";
        } else {
            stylus = "finger";
        }
        // TODO add your handling code here:
    }//GEN-LAST:event_redMenuActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new FinalGUICopy().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JRadioButton blackRadioButton;
    private javax.swing.JRadioButton blueRadioButton;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JButton cameraButton;
    private javax.swing.JButton clearScreen;
    private javax.swing.JMenuItem deviceMenu1;
    private javax.swing.JPanel drawingPanel;
    private javax.swing.JButton eraserButton;
    private javax.swing.JRadioButtonMenuItem fingerMenu;
    private javax.swing.JRadioButton greenRadioButton;
    private javax.swing.JButton imageButton;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenu jMenu5;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem10;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem7;
    private javax.swing.JMenuItem jMenuItem8;
    private javax.swing.JMenuItem jMenuItem9;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JSlider jSlider1;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JToolBar jToolBar2;
    private javax.swing.JMenuItem leftCamMenu;
    private javax.swing.JLabel leftLiveCamLabel;
    private javax.swing.JPanel leftLivecamPanel;
    private javax.swing.JPanel leftPanel;
    private javax.swing.JLabel leftSkinLabel;
    private javax.swing.JPanel leftSkinPanel;
    private javax.swing.JButton penButton;
    private javax.swing.JRadioButtonMenuItem redMenu;
    private javax.swing.JRadioButton redRadioButton;
    private javax.swing.JMenuItem rightCamMenu;
    private javax.swing.JLabel rightLiveCamLabel;
    private javax.swing.JPanel rightPanel;
    private javax.swing.JLabel rightSkinLabel;
    private javax.swing.JButton startButton;
    private javax.swing.JButton stopButton;
    private javax.swing.JMenuItem stopMenu;
    // End of variables declaration//GEN-END:variables
    Action paintTimer = new AbstractAction() {

        public void actionPerformed(ActionEvent e) {

            if (!clearSet) {

                int xx = FinalGUICopy.x;
                int yy = FinalGUICopy.y;

                if ((prevX == 0 && prevY == 0) || (xx == 0 && yy == 0)) {
                } else {
                    g.setColor(linecolor);
                    g.setStroke(new BasicStroke(jSlider1.getValue()));
                    g.fillOval(xx, yy, 5, 5);
                }

                prevX = xx;
                prevY = yy;

                if (viewCamPressed) {
                    System.out.println("came here 1");
                    liveCamViewer();
                    System.out.println("came here 2");
                }
            } else {
                g.drawLine(0, 0, 0, 0);
                drawingPanel.repaint();
                clearSet = false;
            }
        }
    };
    Action paintTimerOld = new AbstractAction() {

        public void actionPerformed(ActionEvent e) {

            if (!clearSet) {

                int xx = FinalGUICopy.x;
                int yy = FinalGUICopy.y;

                if ((prevX == 0 && prevY == 0) || (xx == 0 && yy == 0)) {
                } else {
                    g.setColor(linecolor);
                    g.setStroke(new BasicStroke(jSlider1.getValue()));
                    g.drawLine(prevX, prevY, xx, yy);
                }

                prevX = xx;
                prevY = yy;

                if (viewCamPressed) {
                    liveCamViewer();
                }
            } else {
                g.drawLine(0, 0, 0, 0);
                drawingPanel.repaint();
                clearSet = false;
            }
        }
    };

    public void liveCamViewer() {

        System.out.println("came here 3");
        ic1.setImage(getLiveCam1(0));
         System.out.println("came here 5");
        leftLiveCamLabel.setIcon(ic1);
        System.out.println("came here 4");
        ic2.setImage(getSkin1(0));
        leftSkinLabel.setIcon(ic2);

        ic3.setImage(getLiveCam1(1));
        rightLiveCamLabel.setIcon(ic3);

        ic4.setImage(getSkin1(1));
        rightSkinLabel.setIcon(ic4);

        leftPanel.repaint();
        rightPanel.repaint();
    }

    public void setBackgroundImage() {

        int returnVal = fc.showOpenDialog(this);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            file = fc.getSelectedFile();
            try {
                if (file != null) {
                    bf = ImageIO.read(file);

                    g.drawImage(bf, 0, 0, getWidth(), getHeight(), this);

                }
            } catch (IOException ex) {
                Logger.getLogger(FinalGUICopy.class.getName()).log(Level.SEVERE, null, ex);
            }
        } else {
            System.out.println("cou");
        }

    }
}
